﻿// 显示登录与注册窗口界面
function ShowWindow() {
    $("#txtUserName").val("");
    $("#txtpassword").val("");
    layer.open({
        type: 1,//表示弹出是一个页面层
        title: title,
        area: ["393px", "360px"],//宽度和高度
        content: $("#dloginbox") //内容所对应的jq对象
    });
}

// 登录提交
function Login() {
    var username = $.trim($("#txtUserName").val());//获取到用户名
    var password = $.trim($("#txtPwd").val());//获取到用户名
    var is_remember = 0;
    if($('#rem').is(':checked')) {
        is_remember = 1;
    }
    // 检测用户名、密码是否填写
    if (username == "" || password == "") {
        layer.msg("用户名或密码不能为空", {
            time: 2000,
            icon: 5
        });
    } else {
        $.post(url, { "username": username, "password": password, "remember": is_remember}, function (data) {
            if (data.status == 1) {
                layer.msg(data.info, {
                    time: 2000,
                    icon: 6
                }, function () {
                    location.href = data.url;
                });
            }
            else {
                layer.msg(data.info, {
                    time: 2000,
                    icon: 5
                });
            }
        });
    }
}

// 注册提交
function register() {
    var username = $.trim($("#txtUserName").val());//获取到用户名
    var password = $.trim($("#txtPwd").val());//获取到用户名
    var is_remember = 0;
    // 检测用户名、密码是否填写
    if (username == "" || password == "") {
        layer.msg("用户名与密码必须同时填写", {
            time: 2000,
            icon: 5
        });
    } else {
        $.post(url, { "username": username, "password": password}, function (data) {
            if (data.status == 1) {
                layer.msg(data.info, {
                    time: 2000,
                    icon: 6
                }, function () {
                    location.href = data.url;
                });
            }
            else {
                layer.msg(data.info, {
                    time: 2000,
                    icon: 5
                });
            }
        });
    }
}